#include "CompBioTools.hh"
#include "MerHashMap.hh"


RandomNumberGenerator RNGX;

double gIntRange;

void GetRandomMer(Mer &M)
{
  M.mUpper32 = (unsigned int) RNGX.Uniform(0,gIntRange);
  M.mLower32 = (unsigned int) RNGX.Uniform(0,gIntRange);
}


void main(int argc,char** argv)
{
  Mer M;

  cout<<"short="<<sizeof(short)<<endl;  // 2 bytes
  cout<<"char="<<sizeof(char)<<endl;    // 1 byte

  gIntRange = pow(2,32);
  cout<<"IntRange="<<gIntRange<<endl;

  RNGX.SeedWithClock();
  
  cout<<"Mer size = "<<sizeof(M)<<endl; // 8 bytes. 

  int numMers = atoi(argv[1]);
  int subsetNum = atoi(argv[2]);

  MerSet Mers;
  Mer2IntMap MerMap;
  int inSubsetCount = 0;
  int totalCount = 0;
  for(int i = 0;i< numMers;i++){
  	 GetRandomMer(M);
	 
	 if (M.InSubset(subsetNum)){
		inSubsetCount++;
	 }
	 totalCount++;

	 MerMap[M] = i;
	 MerMap.Add(M);
	 // Mers.Add(M);   // Keep track of all mers, fwd or reverse. 

	 M.ReverseComplement();
	 MerMap.Add(M);
	 //Mers.Add(M);   // Keep track of all mers, fwd or reverse. 

  }
  
  cout<<"Total count = "<<totalCount<<endl;
  cout<<"InSubset = "<<inSubsetCount<<endl;


  cout<<"Record RAM"<<endl;
  string ans;
  cin>>ans;

  /*
  cout<<"Checking that all mers are in Mer2IntMap..."<<endl;
  MerSet::iterator it;
  for(it = Mers.begin();it != Mers.end();it++){
	 Mer testMer = (*it);
	 if (!MerMap.Contains(testMer)){
		Sequence S;
		testMer.ToSequence(S);
		cout<<S<<"\t is not in Mer2IntMap"<<endl;
	 }
  }
  cout<<"done."<<endl;

  cout<<"Mers.size()="<<Mers.size()<<endl;
  */

  cout<<"MerMap.size()="<<MerMap.size()<<endl;
  cout<<"MerMap.total="<<MerMap.mTotalMersInHash<<endl;
  
  
}
